<?php
/**
  * tframe
  *
  *
  * @copyright Copyright (c) 2012 - 2014, huxiaomin
  * @author huxiaomin    2012-7-8  
  * @since		Version 1.0
  *
  */

class TDebug{

    static public $open = DEBUG_TYPE;
    static public $debug = array();
    
    /**
     * 新增debug输出
     * @param string $data
     */
    static public function add($data){
        if (!self::$open){
            return false;
        }
        self::$debug[] = $data;
    }
    
    /**
     * 将当前的debug信息输出
     */
    static public function printDebug($texarea = 1,$log_file = 0,$log_name='TDebug'){
        if (!self::$open){
            return false;
        }
        $content = print_r(self::$debug , 1);
        $rand = rand();
        if ($texarea){
            $content2 = "<br />  <p> <span style='color:red'>调试信息：</span> </p><textarea id='print_debug_{$rand}'cols='120' rows='20'> </textarea>";
                            $arr = json_encode(array('data'=>$content));
                           $content2 .= <<<CON
                            <script> var content = {$arr};\$("#print_debug_{$rand}").val(content.data);</script>
CON;
        }else {
            $content2 = $content;
        }
        if ($log_file){
            TLog::logTemp($content,$log_name);
        }else {
            echo $content2;
        }
        return true;
    }
    
    

}